{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "陈      陈真\n",
      "998    刘培\n",
      "997    李磊\n",
      "996    林逸\n",
      "dtype: object\n",
      "<class 'pandas.core.series.Series'>\n"
     ]
    }
   ],
   "source": [
    "data=['陈真','刘培','李磊','林逸']\n",
    "index=['陈',998,997,996]\n",
    "s = pd.Series(data,index=index)\n",
    "print(s)\n",
    "print(type(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "陈      陈真\n",
      "998    刘培\n",
      "997    李磊\n",
      "996    林逸\n",
      "dtype: object\n",
      "陈真\n",
      "997    李磊\n",
      "998    刘培\n",
      "996    林逸\n",
      "dtype: object\n",
      "切片索引 [start:stop:step]\n",
      "Series([], dtype: object)\n",
      "获取索引\n",
      "Index(['陈', 998, 997, 996], dtype='object')\n",
      "获取值\n",
      "['陈真' '刘培' '李磊' '林逸']\n"
     ]
    }
   ],
   "source": [
    "print(s)\n",
    "# 标签索引\n",
    "print(s['陈']) # 输出不包括索引\n",
    "print(s[[997,998,996]]) # 输出包括索引\n",
    "\n",
    "print('切片索引 [start:stop:step]')\n",
    "print(s[996:998:1]) # 输出不包括索引\n",
    "\n",
    "\n",
    "print('获取索引')\n",
    "print(s.index)\n",
    "\n",
    "print('获取值')\n",
    "print(s.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    zhagnsan\n",
      "1        lisi\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "ser = pd.Series(['zhagnsan','lisi','wangwu'])\n",
    "print(ser[0:2:1]) # 输出不包括索引, [0,2)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
